const {mongoose,db} = require('../utils/mongoose');
const schema = mongoose.Schema({  //表模型
    oId:{type:String,require:false},
    name:{type:String,require:false},
    group:{type:Number,require:false},
    sex:{type:String,require:false},
    age:{type:Number,require:false},
    position:{type:String,require:false},
});
const H1902 = mongoose.model('H1902s',schema);



//增
const addmember = function(data){
    let newmember = new H1902(data);
    return newmember.save()
    .then(res=>res)
    .catch(err=>{
        console.log(err);
        return false;
    })
}
//删
const removemember = function(query = {}){
    return H1902.deleteOne(query)
    .then(res=>res)
    .catch(err=>{
        console.log(err);
        return false;
    })
}
//改
const updatemember = function(query,updatedata){
    return H1902.updateOne(query,updatedata)
    .then(res=>res)
    .catch(err=>{
        console.log(err);
        return false;
    })
}
//查
const getdata = function(query = {}){
    return H1902.find(query)
    .then(res=>res)
    .catch(err=>{
        console.log(err);
        return false;
    })
}

module.exports={
    addmember,
    removemember,
    updatemember,
    getdata
}